﻿@using PEPe.DataAccessModel
@{
    ViewBag.Title = "Agenda Detalhe";
}
@model Agenda

@*OBS: Tem que criar um js dentro da pasta scripts/areas/nomedasessao depois colocar ele no \app_start\BundleConfing.cs*@

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/thema")
@Scripts.Render("~/Areas/Agenda")



<div class="menubar">
    <div class="sidebar-toggler visible-xs">
        <i class="ion-navicon"></i>
    </div>
    <div class="page-title">
        Agenda
        @*<small class="hidden-xs">
                <strong>This form has validation</strong>
            </small>*@
    </div>
</div>
<div class="content-wrapper">
    <form id="form-agenda" name="form-agenda" class="form-horizontal" method="post" action="~/Logado/Agenda/AgendaSalvar" role="form">
        <input type="hidden" id="Id" name="Id" value="@Model.Id" />

        <!--
        <div class="form-group">
            <label class="col-sm-2 col-md-2 control-label">Usuario</label>
            <div class="col-sm-10 col-md-8">
                @Html.DropDownList("ddlUsuario")
            </div>
        </div>
        -->

        <div class="form-group">
            <label class="col-sm-2 col-md-2 control-label">Procedimento</label>
            <div class="col-sm-10 col-md-8">
                @Html.DropDownList("ddlProcedimento")
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 col-md-2 control-label">Consulta</label>
            <div class="col-sm-10 col-md-8">
                @Html.TextArea("consultaDescricao", (Model.Consulta != null && !string.IsNullOrEmpty(Model.Consulta.Descricao)) ? Model.Consulta.Descricao : "", new { maxlenght = "100" })
                <br clear="all" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 col-md-2 control-label">Medicamentos</label>
            <div class="col-sm-10 col-md-8">
                <table>
                    <tr>
                        <td>
                            Descrição
                        </td>
                        <td>
                            <div class="ui-widget">
                                @Html.Hidden("medicamentoDescricaoId", "", new { @maxlenght = "100", @name = "medicamentoDescricaoId" })
                                @Html.TextBox("medicamentoDescricao", "", new { @maxlenght = "100", @name = "medicamentoDescricao" })
                            </div>
                        </td>


                    </tr>
                    <tr>
                        <td><input type="button" value="Incluir" onclick="javascript:salvarMedicamento();" /></td>
                    </tr>
                </table>

                <br clear="all" />

                <div class="content-wrapper">
                    <table border="1" id="tbMedicamentos" class="dataTable">
                        <tr style="background-color:#808080; color:#ffffff">
                            <td>Medicamento</td>
                            <td></td>
                        </tr>
                        @{

                            int i = 0;

                            if (Model.Consulta != null && Model.Consulta.ConsultaMedicamento != null)
                            {
                                foreach (var item in Model.Consulta.ConsultaMedicamento)
                                {

                                    i++;

                                    <tr id="@i">
                                        <td class="sorting_disabled"><input type="hidden" name="medicamento" value="@item.Medicamento.Descricao" />@item.Medicamento.Descricao</td>
                                        <td class="sorting_disabled"><a href="javascript:excluirMedicamento(@i);">Excluir</a></td>
                                    </tr>
                                }
                            }
                        }
                    </table>
                </div>
            </div>

        </div>

        <div class="form-group">
            <label class="col-sm-2 col-md-2 control-label">Data</label>
            <div class="col-sm-10 col-md-8">
                <input type="text" class="form-control datepicker" id="DataHora" name="DataHora" placeholder="09/05/2015" size="30" value="@ViewBag.Data" style="width:80px;" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 col-md-2 control-label">Hora</label>
            <div class="col-sm-10 col-md-8">
                <input type="text" class="form-control" id="hora" name="hora" size="30" value="@ViewBag.Hora" style="width:80px;" />
            </div>
        </div>

        <div class="form-group form-actions">
            <div class="col-sm-offset-2 col-sm-10">
                <a href="form.html" class="btn btn-default">Cancela</a>
                <button type="submit" class="btn btn-success">Registra</button>
            </div>
        </div>
    </form>
</div>

@*<script src="@Url.Content("~/Content/Scripts/vendor/jquery-ui.min.js")" type="text/javascript"></script>*@

<script type="text/javascript">


    // Datepicker
    $('.datepicker').datepicker({
        autoclose: true
    });

    //$(".datepicker").datepicker({
    //    dateFormat: 'dd/mm/yy',
    //    dayNames: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'],
    //    dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S', 'D'],
    //    dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom'],
    //    monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
    //    monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
    //    nextText: 'Próximo',
    //    prevText: 'Anterior'
    //});

    $("#dataIni").mask("99/99/9999");
    $("#dataFim").mask("99/99/9999");






    $(function () {
        $("#medicamentoDescricao").autocomplete({
            source: function (request, response) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "@Url.Action("ConsultaAutocomplete","Agenda")",
                    data: "{'palavraChave':'" + $("#medicamentoDescricao").val() + "'}",
                    dataType: "json",
                    success: function (data) {
                        //$("#medicamentoDescricaoId").val(data.id);
                        response(data);
                    },
                    error: function (result) {
                        //alert("Error");
                    }
                });
            }
        });
    });


    //$(function () {
    //    var availableTags = [
    //      "ActionScript",
    //      "AppleScript",
    //      "Asp",
    //      "BASIC",
    //      "C",
    //      "C++",
    //      "Clojure",
    //      "COBOL",
    //      "ColdFusion",
    //      "Erlang",
    //      "Fortran",
    //      "Groovy",
    //      "Haskell",
    //      "Java",
    //      "JavaScript",
    //      "Lisp",
    //      "Perl",
    //      "PHP",
    //      "Python",
    //      "Ruby",
    //      "Scala",
    //      "Scheme"
    //    ];
    //    $("#medicamentoDescricao").autocomplete({
    //        source: availableTags
    //    });
    //});


</script>
